using System.Collections;
using System.Collections.Generic;
using Sirenix.OdinInspector;
using UnityEngine;

public class GameEntry : MonoBehaviour
{
    public static GameEntry Instance;
    public UIJoysTick uIJoysTick;
    public CameraManager cameraManager;
    public Player player;

    public Dictionary<ResourceState, int> ResourceCounts = new Dictionary<ResourceState, int>();

    void Awake()
    {
        Instance = this;
    }
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {

    }

    public void AddResrouce(ResourceState state,int Count)
    {
        if (ResourceCounts.ContainsKey(state))
        {
            ResourceCounts[state] += Count;
        }
        else
        {
            ResourceCounts.Add(state, Count);
            
        }
    }

    [ReadOnly]
    public List<Entity> entities = new List<Entity>();
    private List<Entity> TempEntities = new List<Entity>();

    public void RegistarEntity(Entity entity)
    {
        if (entities.Contains(entity))
        {
            Debug.LogError("Entity already registered: " + entity.name);
            return;
        }
        entities.Add(entity);
        entity.gameObject.SetActive(true);
        if (!entity.IsInit) {
            entity.OnAwake(); 
        }
        entity.OnStart();
    }

    public void UnRegistarEntity(Entity entity)
    {
        if (!entities.Contains(entity))
        {
            Debug.LogError("Entity not registered: " + entity.name);
            return;
        }
        entities.Remove(entity);
        entity.gameObject.SetActive(false);
        entity.OnClose();
    }
}
